package com.itheima.d2_buffered_stream;

import java.io.*;

/*
    目标：观察原始流和缓冲流的性能。
 */
public class TimeTest4 {
    public static void main(String[] args) throws Exception {

        long l = System.currentTimeMillis();
        copy2();
        long l1 = System.currentTimeMillis();
        System.out.println(l1 - l);
    }

    public static void copy1() throws Exception {
        FileInputStream fis = new FileInputStream("D:\\AAA\\壁纸\\wallhaven\\wallhaven-858k3j.jpg");
        FileOutputStream fos = new FileOutputStream("wallhaven-858k3j.jpg");
        BufferedInputStream bis = new BufferedInputStream(fis);
        BufferedOutputStream bos = new BufferedOutputStream(fos);

        int lin;
        byte[] bytes = new byte[1024];
        while ((lin = bis.read(bytes)) != -1) {
            bos.write(bytes, 0, lin);
        }
        bis.close();
        bos.close();
    }

    public static void copy2() throws Exception {
        FileInputStream fis = new FileInputStream("D:\\AAA\\壁纸\\wallhaven\\wallhaven-858k3j.jpg");
        FileOutputStream fos = new FileOutputStream("wallhaven-858k3j.jpg");

        int lin;
        byte[] bytes = new byte[1024];
        while ((lin = fis.read(bytes)) != -1) {
            fos.write(bytes, 0, lin);
        }
        fis.close();
        fos.close();
    }


}










